<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: urlParamAdd.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: urlParamAdd.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/**
 * **url参数封装(可添加多个)；支持中文字符串传参，输出base-64编码字符串**
 * @param {Json} [datas={}] - url参数
 * @param {String} [url=''] - 需要拼接的域名
 * @returns 返回参数组合，如：name='tom'&amp;age=18
 * 
 * @example
 *
 * ```js
 * urlParamAdd({
 *    name:'tom',
 *    age:18
 * })
 * 
 * //return bmFtZSUzRCVFNSVCQyVBMCVFNCVCOCU4OSUyNmFnZSUzRDIw
 * ```
 * @example
 *
 * ```js
 * * urlParamAdd({
 *    name:'tom',
 *    age:18
 * },'http://localhost:8080')
 * 
 * //return http://localhost:8080?bmFtZSUzRCVFNSVCQyVBMCVFNCVCOCU4OSUyNmFnZSUzRDIw
 * ```
 * 
 */
const urlParamAdd=(datas={},url='')=>{
   let urlData='';
   for(let name in datas){
       urlData+=`${name}=${datas[name]}&amp;`;
   };
   urlData = urlData.substring(0,urlData.length-1)

   // 特殊字符及中文字符串编译    
   urlData=encodeURIComponent(urlData);
   // base64编译
   urlData=window.btoa(urlData);

   // 如果传入域名返回拼接    
   if(url!=''){
       urlData=`${url}?${urlData}`;
   }
   return urlData;
}

export default urlParamAdd;</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#cookieAdd">cookieAdd</a></li><li><a href="global.html#cookieGet">cookieGet</a></li><li><a href="global.html#haveCNChars">haveCNChars</a></li><li><a href="global.html#haveSpace">haveSpace</a></li><li><a href="global.html#isAndroid">isAndroid</a></li><li><a href="global.html#isApple">isApple</a></li><li><a href="global.html#isEmail">isEmail</a></li><li><a href="global.html#isIdCard">isIdCard</a></li><li><a href="global.html#isMail">isMail</a></li><li><a href="global.html#isMobile">isMobile</a></li><li><a href="global.html#isPhone">isPhone</a></li><li><a href="global.html#isQQ">isQQ</a></li><li><a href="global.html#isTel">isTel</a></li><li><a href="global.html#isTest">isTest</a></li><li><a href="global.html#isURL">isURL</a></li><li><a href="global.html#isWeixin">isWeixin</a></li><li><a href="global.html#lengthRange">lengthRange</a></li><li><a href="global.html#letterBegin">letterBegin</a></li><li><a href="global.html#localStorageAdd">localStorageAdd</a></li><li><a href="global.html#localStorageGet">localStorageGet</a></li><li><a href="global.html#pureNum">pureNum</a></li><li><a href="global.html#sessionStorageAdd">sessionStorageAdd</a></li><li><a href="global.html#sessionStorageGet">sessionStorageGet</a></li><li><a href="global.html#strDelRight">strDelRight</a></li><li><a href="global.html#strJoin">strJoin</a></li><li><a href="global.html#strTrim">strTrim</a></li><li><a href="global.html#timeStamp">timeStamp</a></li><li><a href="global.html#totalPage">totalPage</a></li><li><a href="global.html#urlParamAdd">urlParamAdd</a></li><li><a href="global.html#urlParamGet">urlParamGet</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Mon Nov 22 2021 17:08:01 GMT+0800 (中国标准时间)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
